package com.example.heizhu.appfuncore;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;

import com.zhy.http.okhttp.OkHttpUtils;
import com.zhy.http.okhttp.callback.StringCallback;

import core.android.deeplinks.deeplinking.AKDeeplink;
import core.android.deeplinks.deeplinking.annotations.DeeplinkDefaultRoute;
import core.android.tools.AKActivityUtil;
import core.android.tools.AK;
import core.android.tools.AKPathUtil;
import okhttp3.Call;


@DeeplinkDefaultRoute
public class RouteActivity extends AppCompatActivity {
    OKUploadImageView imageView;
    Button testView;
    String path;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_route);
        AKActivityUtil.INSTANCE.setApplication(getApplication());
        AKDeeplink.INSTANCE.initDeeplinking(this);

//        Deeplinking.INSTANCE.openURL("http://www.zcwd.com/html5?url=https://www.sogou.com/&referrer=baidu.com");
        //Deeplinking.INSTANCE.openURL("http://www.zcwd.com/qrcode");//启动扫一扫

        path = AKPathUtil.getInstance().getImageDir().getAbsolutePath() + "/qingxing_feiji.jpg";

        imageView = (OKUploadImageView) findViewById(R.id.okuploadimageview);
        testView = (Button) findViewById(R.id.btn);
        testView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
//                Deeplinking.INSTANCE.openURL(DeepLinkScheme.INDEX);
//                OkUploadFileTool.okhttpUpload();
                OkHttpUtils.getInstance().cancelTag(path);
            }
        });
        imageView.setImagePath(path);

        imageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                imageView.upload(new StringCallback() {
                    @Override
                    public void onError(Call call, Exception e, int i) {

                    }

                    @Override
                    public void onResponse(String s, int i) {
                        AK.e(s);
                    }
                });
            }
        });

    }


}
